package ${cfg.controllerPackage};

import com.sbtr.common.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.sbtr.exception.BDException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.sbtr.common.PageDto;
import ${package.Entity}.${entity};
import ${cfg.controllerPackage}.dto.${entity}Dto;
import ${package.Service}.${table.serviceName};
<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
import com.sbtr.controller.common.${superControllerClass};

/**
 * ${table.comment!} 前端控制器
 *
 * @author ${author}
 * @since ${date}
 */
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("${cfg.terminal}/${'${entity}'?uncap_first}")
@Api(tags = "${table.comment!}")
<#if superControllerClass??>
public class ${cfg.controllerNamePrefix}${table.controllerName} extends ${superControllerClass}<${entity},${table.serviceName}> {
<#else>
public class ${cfg.controllerNamePrefix}${table.controllerName} {
</#if>

    @GetMapping("/pageList")
    @ApiOperation(httpMethod = "GET", value = "分页列表")
    public Response<PageDto<${entity}>> pageList(${entity}Dto ${'${entity}'?uncap_first}Dto){
        return Response.success(u.pageList(${'${entity}'?uncap_first}Dto));
    }

    @PostMapping("/save")
    @ApiOperation(httpMethod = "POST", value = "保存")
    public Response<${entity}> save(@RequestBody ${entity} ${'${entity}'?uncap_first}){
        ${'${entity}'?uncap_first}.setId(null);
        if(${'${entity}'?uncap_first}.insert()){
            return Response.success(${'${entity}'?uncap_first});
        }else throw new BDException("保存失败");
    }

}

